<?php

use Fluency\Request;

return array(
    "h" => "htmlspecialchars",

    "urlTo" => function($action, array $params = array()) use ($self) {
        $url = $self->getService("router")->createUrl($action, $params);
        return $self->getService("baseUrl") . "/" . $url;
    },

    "execute" => function($action, array $params = array(), $format = null) use ($self) {
        $format = $format ?: constant(get_class($self) . "::DEFAULT_FORMAT");
        $req = Request::forAction($action)->withParameters($params)->preferringFormat($format);
        return $self->getService("dispatcher")->dispatch($req->withInternalScope());
    },
);